﻿using Digitalmes.Domain.Entities.Mes.Masters;

namespace Digitalmes.Application.Mes.Masters.Workstations.Commands;

/// <summary>
/// 删除工位命令。
/// </summary>
/// <param name="WsId"></param>
public record DeleteWorkstationCommand(long WsId) : IRequest<IResult<bool>>;

internal sealed class DeleteWorkstationCommandHandler(IRepository<MdWorkstation> repo) : IRequestHandler<DeleteWorkstationCommand, IResult<bool>>
{
    public async Task<IResult<bool>> Handle(DeleteWorkstationCommand request, CancellationToken cancellationToken)
    {
        var ok = await repo.DeleteByIdAsync(request.WsId, cancellationToken);
        return Result.From(ok);
    }
}
